const mysql = require('mysql2/promise');

// 数据库连接配置
const dbConfig = {
  host: 'localhost',
  user: 'root',
  password: 'root',
  database: 'community_service_platform',
  port: 3306
};

async function checkData() {
  try {
    console.log('🔍 正在检查数据库数据...');
    
    // 创建连接
    const connection = await mysql.createConnection(dbConfig);
    console.log('✅ 数据库连接成功！');
    
    // 检查闲置物品表
    console.log('\n📋 检查闲置物品表...');
    const [idleItems] = await connection.execute('SELECT * FROM idle_items LIMIT 5');
    console.log(`闲置物品数量: ${idleItems.length}`);
    if (idleItems.length > 0) {
      console.log('示例数据:', idleItems[0]);
    }
    
    // 检查技能表
    console.log('\n📋 检查技能表...');
    const [skills] = await connection.execute('SELECT * FROM skills LIMIT 5');
    console.log(`技能数量: ${skills.length}`);
    if (skills.length > 0) {
      console.log('示例数据:', skills[0]);
    }
    
    // 检查服务表（可能包含模拟数据）
    console.log('\n📋 检查服务表...');
    const [services] = await connection.execute('SELECT * FROM services LIMIT 5');
    console.log(`服务数量: ${services.length}`);
    if (services.length > 0) {
      console.log('示例数据:', services[0]);
    }
    
    await connection.end();
    console.log('\n✅ 数据检查完成！');
    
  } catch (error) {
    console.error('❌ 检查失败:', error.message);
  }
}

checkData(); 